package com.web.app.ctrl;

import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.web.app.config.PageConfig;
import com.web.app.dao.TestkeyMapper;
import com.web.app.pojo.Testkey;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.web.bind.annotation.*;

import javax.annotation.Resource;
import java.util.List;

/**
 * @author JMLF
 * @date 2022-09-21
 */
@RestController
@CrossOrigin
public class TestCtrl {

    @Autowired
    private TestkeyMapper testkeyDao;

    @RequestMapping("/testKey02")
    public List<Testkey> selectTestKey02(long size, long pageindex){
        //使用时候用Page泛型所指向的就是我们需要的实体类
        Page<Testkey> page = new Page<>();
        page.setSize(size);//每页条数
        page.setCurrent(pageindex);//当前页

        //page.setCountId("key1");
        Page<Testkey> orderTblPage = testkeyDao.selectPage(page, null);
        System.err.println("查询结果列表大小:"+orderTblPage.getRecords().size());
        System.err.println("总条数:"+orderTblPage.getTotal());
        System.err.println("countId:"+orderTblPage.getCountId());
        System.err.println("当前页:"+orderTblPage.getCurrent());
        System.err.println("每页显示条数，默认 10:"+orderTblPage.getSize());
        System.err.println("最大分页条数限制:"+orderTblPage.getMaxLimit());
        System.err.println("总页数:"+orderTblPage.getPages());
        for(Testkey kk : orderTblPage.getRecords()){
            System.out.println(kk);
        }
        return orderTblPage.getRecords();
    }

}
